package com.firewolf.wx.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.firewolf.wx.dao.HomeDao;
import com.firewolf.wx.entities.CommonCategory;
import com.firewolf.wx.entities.CommonGoods;
import com.firewolf.wx.entities.LunBo;
import com.firewolf.wx.entities.Renwu;
import com.firewolf.wx.entities.Tuijian;
import com.firewolf.wx.entities.Xuanyou;
import com.firewolf.wx.service.HomeService;
import com.firewolf.wx.web.WxContext;

@Service
public class HomeServiceImpl implements HomeService {

	@Autowired
	private WxContext wxContext;

	@Autowired
	private HomeDao homeDao;

	@Override
	public List<LunBo> lunboList() {
		List<LunBo> lunboList = homeDao.lunboList();
//		for (LunBo l : lunboList) {
//			l.setImgUrl(wxContext.getImgserverUrl() + l.getImgUrl());
//		}
		return lunboList;
	}

	@Override
	public List<Tuijian> tuijianList() {
		// TODO Auto-generated method stub
		List<Tuijian> tuijianList = homeDao.tuijianList();
//		for (Tuijian t : tuijianList) {
//			t.setImg(wxContext.getImgserverUrl() + t.getImg());
//		}
		return tuijianList;
	}

	@Override
	public List<Renwu> renwuList() {
		// TODO Auto-generated method stub
		List<Renwu> renwuList = homeDao.renwuList();
//		for (Renwu r : renwuList) {
//			r.setImg(wxContext.getImgserverUrl() + r.getImg());
//		}
		return renwuList;
	}

	@Override
	public List<Xuanyou> xuanyou() {
		List<Xuanyou> xuanyouList = homeDao.xuanyouList();
//		for (Xuanyou x : xuanyouList) {
//			x.setImg(wxContext.getImgserverUrl() + x.getImg());
//		}
		return xuanyouList;
	}

	@Override
	public List<CommonCategory> commoncategory() {
		List<CommonCategory> commonList = homeDao.commonList();
		return commonList;
	}

	@Override
	public List<CommonGoods> commongoods(Integer pageIndex, Integer pageSize, Integer categoryId) {
		// TODO Auto-generated method stub
		List<CommonGoods> commonGoods = homeDao.commonGoods((pageIndex - 1) * pageSize, pageSize, categoryId);
//		for (CommonGoods c : commonGoods) {
//			c.setImg(wxContext.getImgserverUrl() + c.getImg());
//		}
		return commonGoods;
	}

}
